package com.fh.auth;

import org.springframework.http.server.reactive.ServerHttpRequest;

import java.util.regex.Pattern;

/**
 * @Description:
 * @author： qiujunda
 * @date： 2020/12/18 11:32
 */
public class RegValidator implements BlackWhiteListValidator {
    @Override
    public boolean validate(ServerHttpRequest serverHttpRequest,BlackWhiteList blackWhiteList) {
        String path=serverHttpRequest.getPath().value();
        String regStr=blackWhiteList.getUri();
        regStr=regStr.replaceAll("\\*",".*");
        return Pattern.matches(regStr, path);
    }

}
